package ch.ethz.fcl.metrobuzz.data;

public class WeightedAverage {
	int weight = 0;
	float average = 0;

	public WeightedAverage() {

	}

	public void add(int w, float a) {
		if (this.weight == 0) {
			this.weight = w;
			this.average = a;
		} else {
			this.average = (a * w + average * weight) / (w + weight);
			this.weight += w;
		}
	}

	public int getWeight() {
		return this.weight;
	}

	public float getAverage() {
		return average;
	}
}
